﻿function Url(page)
{
    this.page = page;
    this.parameters = new Array();
        		
    this.toString = Url_ToString;
    this.addParameter = Url_AddParameter;
}

function Url_ToString()
{
    var result = this.page;
    
    for(var i=0; i<this.parameters.length; i++)
    {
        if(Common.isArray(this.parameters[i].value)) {
            result += ((i==0) ? "?" : "&") + this.parameters[i].id + "=" + this.parameters[i].value.join('|');
        }
        else {
            result += ((i==0) ? "?" : "&") + this.parameters[i].id + "=" + Common.urlencode(this.parameters[i].value);
        }
    }
    
    return result;
}

function Url_AddParameter(id, value)
{
    var param = {id:id, value:value};
    this.parameters.push(param);
}
